<?php

declare(strict_types=1);

namespace App\Request\User;

use App\Request\BaseCommonRequest;
use Hyperf\Context\Context;
use Hyperf\Validation\Request\FormRequest;

class PerfectRequest extends BaseCommonRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'sex' => 'required',
            'nickname' => 'required|unique:tb_user',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息
     */
    public function messages(): array
    {
        $language = Context::get('language');
        if ($language == 'zh-cn') {
            return [
                'required' => ':attribute不能为空',
                'unique' => ':attribute已存在'
            ];
        } elseif ($language == 'zh-hk') {
            return [
                'required' => ':attribute不能為空',
                'unique' => ':attribute已存在'
            ];
        } else {
            return [
                'required' => ':attribute field is required.',
                'unique' => ':attribute already exists'
            ];
        }

    }

}